package com.csust.travel.controller;

import com.csust.travel.entity.CollegeReport;
import com.csust.travel.entity.ResBean;
import com.csust.travel.mapper.CollegeReportMapper;
import org.apache.ibatis.javassist.expr.NewArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/collegereport")
public class CollegeReportController {

    @Autowired
    CollegeReportMapper collegeReportMapper;

    @RequestMapping("/report")
    public ResBean collegeR(){
        List<CollegeReport> nameAndNumber = collegeReportMapper.findNameAndNumber();
       List<String>x = new ArrayList<>();
       List<Integer>y =new ArrayList<>();
        for (CollegeReport collegeReport : nameAndNumber) {
            x.add(collegeReport.getCollege());
            y.add(collegeReport.getValue());
        }
        Map<String,List> map = new HashMap<>();
        map.put("x",x);
        map.put("y",y);
      return new ResBean(true,null,map);

    }

}
